package thread;

// 注意区别run和start
// start是创建线程， run是方法的调用

public class Demo3 {
    static class MyThread extends Thread {
        @Override
        public void run() {
            while (true) {
                System.out.println("hello thread");
                try {
                    Thread.sleep(1000);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }
        }
    }

    public static void main(String[] args) {
        MyThread myThread = new MyThread();
        myThread.run();  // 调用方法：只能出现 hello thread
        // myThread.start(); // 调用线程：交叉出现

        while (true) {
            System.out.println("hello main");
            try {
                Thread.sleep(1000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
    }
}
